import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:study_flutter/router/NavigatorUtils.dart';
import 'package:study_flutter/router/Routes.dart';
import 'package:study_flutter/yzhg/routespath/RoutesPath.dart';

/*
 *  三方路由框架  地址：https://pub.dev/packages/fluro
 *  为何放弃原生的框架：
 *      原生跳转局限性太大  只能在StatelessWidget跳转   无法在State中使用
 */

class YFluroRouter extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: new Text("三方路由跳转"),
      ),
      body: Container(
        padding: EdgeInsets.all(ScreenUtil().setSp(50.0)),
        child: Column(
          children: <Widget>[
            RaisedButton(
              onPressed: () {
                NavigatorUtils.push(context, RoutesPath.parameterPath,
                    replace: false);
              },
              child: Text("不带参数跳转，返回时不带回反参"),
            ),
            RaisedButton(
              onPressed: () {
                NavigatorUtils.push(context,
                    '${RoutesPath.noParameterPath}?param1=${Uri.encodeComponent('我是参数param1')}&param2=${Uri.encodeComponent('我是参数param2')}',replace: false);
              },
              child: Text("带参数跳转，返回时带回反参"),
            )
          ],
        ),
      ),
    );
  }
}
